<?php
namespace App\Services\File;
use App\Services\File\File\FileLogic;
/**
 * @Author: ws
 * @Date:   2018-06-12 16:23:45
 * @Last Modified by:   Marte
 */
class File
{
    //上传文件
    public function upload($request)
    {
        if (!isset($_FILES['files']) && !isset($_FILES['file'])) {
            return auto_failure(['res' => false], '上传文件不存在');
        }
        if (!isset($_FILES['files']) && isset($_FILES['file'])) {
            $_FILES['files'] = $_FILES['file'];
        }
        return (new FileLogic())->checkFile($request);
    }

    public function fileDelete($data)
    {
        if (empty($data)) {
            return null_data($data,"参数不能为空！");
        }
        $data = init_array($data, ['id'=>'']);
        ValidateFile::checkValidate($data, ['id']);
        return (new FileLogic())->fileDelete($data);
    }

    public function fileGain($data)
    {
        if (empty($data)) {
            return null_data($data,"参数不能为空！");
        }
        $data = init_array($data, ['id'=>'']);
        ValidateFile::checkValidate($data, ['id']);
        return (new FileLogic())->fileGain($data);
    }
}
